package com.social.controller;

import com.social.pojo.Menu;
import com.social.pojo.Result;
import com.social.service.impl.MenuServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.websocket.server.PathParam;

/**
 * @className: MenuController
 * @description: TODO 类描述
 * @author: XiaoXu
 * @date: 2022/10/30 16:17
 **/

@Api(tags = "MenuController")
@RestController
@RequestMapping("/menu")
public class MenuController {
    @Resource
    private MenuServiceImpl menuService;

    @GetMapping("/list/{path}")
    public Result getMenuByPath(@PathVariable("path") String path){
        return menuService.getMenuByPath(path);
    }

    @PostMapping
    public Result insert(@Valid @RequestBody Menu menu){
        return menuService.insert(menu);
    }

    @PutMapping
    public Result updateMenu(@Valid @RequestBody Menu menu){
        return menuService.updateMenu(menu);
    }

    @PutMapping("/delete")
    public Result deleteMenu(@Valid @RequestBody Menu menu){
        return menuService.deleteMenu(menu);
    }
}
